package fstvis;

import java.awt.Dimension;
import javax.swing.GroupLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class PlotFrame extends JFrame {
	private static final long serialVersionUID = 1L;
	ColourBar cb;
	
	public PlotFrame(FstData data, Stats s, double min, double max) {
		// Get our colour bar
		cb = new ColourBar(min, max, 5, 10);
		
		JPanel p = new PlotPanel(data, cb);
	    p.setOpaque(true); //content panes must be opaque

	    JLabel title = new JLabel(data.getSpecies() + " at t=" + data.getTime() + ", layer=" + data.getLayer());
	    
	    JPanel panel = new JPanel(); 

	    // Put things in our frame
	    GroupLayout layout = new GroupLayout(panel);
	    panel.setLayout(layout);
	    layout.setAutoCreateGaps(true);
	    layout.setAutoCreateContainerGaps(true);

	    cb.setMinimumSize(new Dimension(200, 300));
	    
	    layout.setHorizontalGroup(
	    		   layout.createSequentialGroup()
	    		      .addComponent(cb)
	    		      .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
	    		    		  .addComponent(title)
	    		    		  .addComponent(p))
	    		);
	    		layout.setVerticalGroup(
	    		   layout.createSequentialGroup()
	    		      .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
	    		           .addComponent(cb)
	    		           .addComponent(title)
	    		           .addComponent(p))
	    		);
	
	    //Display the window.
		this.add(panel);
	    this.pack();
	    this.setVisible(true);
	}
}
